/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bsc.ejb.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

/**
 *
 * @author memozac
 */
@Entity
public class Topic implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long idTopic;

    @ManyToMany(targetEntity=ScoreView.class)
    @JoinTable(name="TopicScoreView",
    joinColumns=@JoinColumn(name="idTopic"),
    inverseJoinColumns=@JoinColumn(name="idScoreView"))
    private Collection<ScoreView> scoreViews;

    @ManyToMany(targetEntity=SRM.class)
    @JoinTable(name="SRMTopic",
    joinColumns=@JoinColumn(name="idTopic"),
    inverseJoinColumns=@JoinColumn(name="idSRM"))
    private Collection<SRM> SRMs;

    @ManyToOne
    private ScoreCard scoreCard;

    @Column(columnDefinition="text")
    private String topic;
    
    public Collection<SRM> getSRMs() {
        return SRMs;
    }

    public void setSRMs(Collection<SRM> SRMs) {
        this.SRMs = SRMs;
    }

    public Long getIdTopic() {
        return idTopic;
    }

    public void setIdTopic(Long idTopic) {
        this.idTopic = idTopic;
    }

    public ScoreCard getScoreCard() {
        return scoreCard;
    }

    public void setScoreCard(ScoreCard scoreCard) {
        this.scoreCard = scoreCard;
    }

    public Collection<ScoreView> getScoreViews() {
        return scoreViews;
    }

    public void setScoreViews(Collection<ScoreView> scoreViews) {
        this.scoreViews = scoreViews;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTopic != null ? idTopic.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Topic)) {
            return false;
        }
        Topic other = (Topic) object;
        if ((this.idTopic == null && other.idTopic != null) || (this.idTopic != null && !this.idTopic.equals(other.idTopic))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bsc.ejb.entity.Topic[id=" + idTopic + "]";
    }
}//ends of class
